package cn.smxy.client;

import cn.smxy.config.MultipartSupportConfig;
import cn.smxy.excel.UserExcel;
import cn.smxy.param.CampusRemoveParam;
import cn.smxy.param.CampusSearchParam;
import cn.smxy.param.PageParam;
import cn.smxy.param.UserSearchParam;
import cn.smxy.pojo.Campus;
import cn.smxy.pojo.User;
import cn.smxy.util.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.net.MalformedURLException;
import java.util.List;

@FeignClient(value = "user-service", path = "/user", configuration = MultipartSupportConfig.class)
public interface UserClient {

    /**
     * 返回用户基本信息接口
     *
     * @param userId 用户id
     * @return
     */
    @GetMapping("/basic/{userId}")
    User basic(@PathVariable Long userId);

    /**
     * excel批量导入接口
     *
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping(value = "/save/excel", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R saveExcel(@RequestPart("file") MultipartFile file) throws IOException;

    /**
     * 图片上传接口
     * @param img
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Object upload(@RequestPart("img") MultipartFile img) throws Exception;

    /**
     * 分页展示用户接口
     *
     * @param pageParam
     * @return
     */
    @PostMapping("/page")
    R page(@RequestBody PageParam pageParam);

    /**
     * 修改用户信息接口
     *
     * @param user
     * @return
     */
    @PutMapping("/update")
    R update(@RequestBody User user);

    /**
     * 删除用户接口
     *
     * @param userId
     * @return
     */
    @DeleteMapping("/delete/{userId}")
    R delete(@PathVariable Long userId);

    /**
     * 用户注册接口
     *
     * @param user
     * @return
     */
    @PostMapping("/register")
    R register(@RequestBody User user);

    /**
     * 模糊分页查询用户名接口
     * @param userSearchParam
     * @return
     */
    @PostMapping("/search")
    R search(@RequestBody UserSearchParam userSearchParam);

    /**
     * 返回用户名和用户头像接口
     * @param userId
     * @return
     */
    @GetMapping("/info/{userId}")
    User getUserName(@PathVariable Long userId);

    /**
     * excel导出接口
     * @return
     * @throws MalformedURLException
     */
    @PostMapping("/all")
    List<UserExcel> getAll() throws MalformedURLException;

    /**
     * 分页展示校园认证接口
     * @param campusSearchParam
     * @return
     */
    @PostMapping("/campus/page")
    R campusPage(@RequestBody CampusSearchParam campusSearchParam);

    /**
     * 校园学生认证接口
     * @param campus
     * @return
     */
    @PostMapping("/campus/check")
    R check(@RequestBody Campus campus);

    /**
     * 校园认证批量删除接口
     *
     * @param campusRemoveParam
     * @return
     */
    @PostMapping("/campus/remove/batch")
    R campusRemoveBatch(@RequestBody CampusRemoveParam campusRemoveParam);
}
